﻿using System;
using System.Collections.Generic;
using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;

namespace TestDxfDocument
{
    class SolidReamers
    {
        public static void CylindricalReamer(Dictionary<string, Object> data)  //圆柱铰刀
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double l = Convert.ToDouble(data["l"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double bhta = 45 * pi / 180;
            double plgl = Convert.ToDouble(data["plgl"]) * scale;
            double plgang = Convert.ToDouble(data["plgang"]) * pi / 180;
            double fha = Convert.ToDouble(data["fha"]);//89.99,75
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double tg = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    tg = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    tg = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    tg = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    tg = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    tg = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    tg = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    tg = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                tg = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if (ccms == "ZYL")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v5 = new Vector2(v4.X, -oal + l + (dc - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(dc / 2, -oal + l);
                Vector2 v7 = new Vector2(v6.X, -oal + plgl);
                Vector2 v8 = new Vector2(v7.X - plgl * Math.Tan(plgang), -oal);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v11 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v19, v20 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v17, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v16, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v15, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v14, v5 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v13, v6 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v12, v7 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Line Line26 = new Line(v11, v12);
                Line Line27 = new Line(v20, new Vector2(v20.X, v12.Y));
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 3.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, v8), offset * 2 + v3.X / 2 - v8.X / 2, 270, dimensionStyle);
                dim1.UserText = "L = " + Math.Round(l / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v12, v7), -offset - plgl, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                if (plgl != 0)
                {
                    LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + v3.X - (v7.X + v8.X) / 2, 270, dimensionStyle);
                    dim3.UserText = "PLGL = " + Math.Round(plgl / scale, 2);
                    dxf.AddEntity(dim3);
                }
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v7.X - (v3.X + v6.X) / 2, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                if (dconms >= dc)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + v2.X - (v1.X + v8.X) / 2, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + v6.X - (v8.X + v1.X) / 2, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                if (plgl != 0)
                {
                    Angular2LineDimension angdim7 = new Angular2LineDimension(Line26, Line27, ls, dimensionStyle);
                    angdim7.UserText = "PLGANG = " + Math.Round(plgang / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim7);
                }
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //填充螺旋槽
                LwPolyline hatchpoly2 = new LwPolyline();
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v7));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v12));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly2.IsClosed = true;
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)hatchpoly2.Explode()[i];
                    }
                }
                var x = l / 5.00 * Math.Tan(fha * pi / 180);
                if (x < dc / 2.00)
                {
                    if (fha == 75)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 2.00 * 5 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                    if (fha == 89.99)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 2.00 * 2 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                }
                else
                {
                    if (fha == 75)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 5.00 * 5 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                    if (fha == 89.99)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 5.00 * 2 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                }
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / tg;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + tg * tg / 4)) * tg / 2, -Math.Sqrt(0.25 / (1 + tg * tg / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + l + (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(dc / 2, -oal + l);
                Vector2 v7 = new Vector2(v6.X, -oal + plgl);
                Vector2 v8 = new Vector2(v7.X - plgl * Math.Tan(plgang), -oal);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc3 = new LwPolyline();
                Arc3.Vertexes.Add(new LwPolylineVertex(v3));
                Arc3.Vertexes.Add(new LwPolylineVertex(v4));
                Arc3.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v11 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                LwPolyline Arc15 = new LwPolyline();
                Arc15.Vertexes.Add(new LwPolylineVertex(v15));
                Arc15.Vertexes.Add(new LwPolylineVertex(v16));
                Arc15.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v19, v20 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v17, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v16, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v15, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v14, v5 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v13, v6 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v12, v7 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Line Line26 = new Line(v11, v12);
                Line Line27 = new Line(v20, new Vector2(v20.X, v12.Y));
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 3.5;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 3.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, v8), offset * 2 + v3.X - (v8.X + v6.X) / 2, 270, dimensionStyle);
                dim1.UserText = "L = " + Math.Round(l / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v12, v7), -offset - plgl, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                if (plgl != 0)
                {
                    LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + v3.X - (v7.X + v8.X) / 2, 270, dimensionStyle);
                    dim3.UserText = "PLGL = " + Math.Round(plgl / scale, 2);
                    dxf.AddEntity(dim3);
                }
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + v3.X - (v1.X + v8.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸7
                if (plgl != 0)
                {
                    Angular2LineDimension angdim7 = new Angular2LineDimension(Line26, Line27, offset, dimensionStyle);
                    angdim7.UserText = "PLGANG = " + Math.Round(plgang / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim7);
                }
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                RadialDimension dimrad1 = new RadialDimension(new Vector2(offset * 2, offset * 2), new Vector2(0, 0), offset * 2, dimensionStyle);//DimensionStyle.Default);
                dimrad1.UserText = "CCMS = " + ccms + ",CZC=" + czc;
                dxf.AddEntity(dimrad1);
                //填充螺旋槽
                LwPolyline hatchpoly2 = new LwPolyline();
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v7));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v12));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly2.IsClosed = true;
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)hatchpoly2.Explode()[i];
                    }
                }
                var x = l / 5.00 * Math.Tan(fha * pi / 180);
                if (x < dc / 2.00)
                {
                    if (fha == 75)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 2.00 * 5 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                    if (fha == 89.99)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 2.00 * 2 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                }
                else
                {
                    if (fha == 75)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 5.00 * 5 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                    if (fha == 89.99)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 5.00 * 2 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                }
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            fun.SetLayer(dxf);

            fun.SetByLayer(dxf);
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void TaperedReamer(Dictionary<string, Object> data)  //锥度铰刀
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dcn = Convert.ToDouble(data["dcn"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double l = Convert.ToDouble(data["l"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double bhta = 45 * pi / 180;
            double ldc = Convert.ToDouble(data["ldc"]) * scale;
            double dtan = dcn - 2 * ldc * Math.Tan(sig / 2);
            double dtax = dtan + 2 * l * Math.Tan(sig / 2);
            double fha = Convert.ToDouble(data["fha"]);//89.99,75
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double tg = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    tg = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    tg = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    tg = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    tg = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    tg = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    tg = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    tg = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                tg = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            if (ccms == "ZYL")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v5 = new Vector2(v4.X, -oal + l + (dtax - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(dtax / 2, -oal + l);
                Vector2 v7 = new Vector2(dcn / 2, -oal + ldc);
                Vector2 v8 = new Vector2(dtan / 2, -oal);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line8 = { v8, v11 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line12 = { v11, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v19, v20 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v17, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v16, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v15, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v14, v5 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v13, v6 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Line Line26 = new Line(v11, v13);
                Line Line27 = new Line(v8, v6);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, v8), offset * 2 + v3.X / 2 - v8.X / 2, 270, dimensionStyle);
                dim1.UserText = "L = " + Math.Round(l / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v12, v7), -offset * 2 - ldc, 0, dimensionStyle);
                dim2.UserText = "DCN = " + Math.Round(dcn / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + v3.X - (v7.X + v8.X) / 2, 270, dimensionStyle);
                dim3.UserText = "LDC = " + Math.Round(ldc / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v6.X - (v3.X + v6.X) / 2, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                if (dconms >= dtax)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + v2.X - (v1.X + v8.X) / 2, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + v6.X - (v8.X + v1.X) / 2, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                Angular2LineDimension angdim7 = new Angular2LineDimension(Line26, Line27, offset + l + dtan / 2 / Math.Tan(sig / 2), dimensionStyle);
                angdim7.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v13, v6), -offset, 0, dimensionStyle);
                dim9.UserText = "DTAX = " + Math.Round(dtax / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v11, v8), -offset, 0, dimensionStyle);
                dim10.UserText = "DTAN = " + Math.Round(dtan / scale, 2);
                dxf.AddEntity(dim10);
                //填充螺旋槽
                LwPolyline hatchpoly2 = new LwPolyline();
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v8));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v11));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly2.IsClosed = true;
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)hatchpoly2.Explode()[i];
                    }
                }
                var x = l / 5.00 * Math.Tan(fha * pi / 180);
                if (x < dcn / 2.00)
                {
                    if (fha == 75)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 2.00 * 2 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                    if (fha == 89.99)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 2.00 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                }
                else
                {
                    if (fha == 75)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 5.00 * 2 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                    if (fha == 89.99)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 5.00 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                }
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / tg;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + tg * tg / 4)) * tg / 2, -Math.Sqrt(0.25 / (1 + tg * tg / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + l + (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                Vector2 v6 = new Vector2(dtax / 2, -oal + l);
                Vector2 v7 = new Vector2(dcn / 2, -oal + ldc);
                Vector2 v8 = new Vector2(dtan / 2, -oal);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc3 = new LwPolyline();
                Arc3.Vertexes.Add(new LwPolylineVertex(v3));
                Arc3.Vertexes.Add(new LwPolylineVertex(v4));
                Arc3.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line8 = { v8, v11 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line12 = { v11, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                LwPolyline Arc15 = new LwPolyline();
                Arc15.Vertexes.Add(new LwPolylineVertex(v15));
                Arc15.Vertexes.Add(new LwPolylineVertex(v16));
                Arc15.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v19, v20 };
                fun.drawPlinetype(dxf, Line19, 0.15, center, Linetype.Center);
                Vector2[] Line20 = { v17, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v16, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v15, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v14, v5 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v13, v6 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Line Line26 = new Line(v11, v13);
                Line Line27 = new Line(v8, v6);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 3.5;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 3.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, v8), offset * 2 + v3.X / 2 - v8.X / 2, 270, dimensionStyle);
                dim1.UserText = "L = " + Math.Round(l / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v12, v7), -offset * 2 - ldc, 0, dimensionStyle);
                dim2.UserText = "DCN = " + Math.Round(dcn / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + v3.X - (v7.X + v8.X) / 2, 270, dimensionStyle);
                dim3.UserText = "LDC = " + Math.Round(ldc / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                if (dconms >= dtax)
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + v2.X - (v1.X + v8.X) / 2, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                else
                {
                    LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + v6.X - (v8.X + v1.X) / 2, 270, dimensionStyle);
                    dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim5);
                }
                //尺寸7
                Angular2LineDimension angdim7 = new Angular2LineDimension(Line26, Line27, offset*2 + l + dtan / 2 / Math.Tan(sig / 2), dimensionStyle);
                angdim7.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v13, v6), offset, 0, dimensionStyle);
                dim9.UserText = "DTAX = " + Math.Round(dtax / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v11, v8), -offset, 0, dimensionStyle);
                dim10.UserText = "DTAN = " + Math.Round(dtan / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                RadialDimension dimrad11 = new RadialDimension(new Vector2(offset * 2, offset * 2), new Vector2(0, 0), offset * 2, dimensionStyle);//DimensionStyle.Default);
                dimrad11.UserText = "CCMS = " + ccms + ",CZC=" + czc;
                dxf.AddEntity(dimrad11);
                //填充螺旋槽
                LwPolyline hatchpoly2 = new LwPolyline();
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v8));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v11));
                hatchpoly2.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly2.IsClosed = true;
                String[] htype2 = new String[100];
                Line[] hline2 = new Line[100];
                int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst2; i++)
                {
                    htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype2[i] == "Line")
                    {
                        hline2[i] = (Line)hatchpoly2.Explode()[i];
                    }
                }
                var x = l / 5.00 * Math.Tan(fha * pi / 180);
                if (x < dcn / 2.00)
                {
                    if (fha == 75)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 2.00 * 2 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                    if (fha == 89.99)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 2.00 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                }
                else
                {
                    if (fha == 75)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 5.00 * 2 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                    if (fha == 89.99)
                    {
                        fun.hatchsuboflinew(dxf, htype2, hnumst2, -fha, l / 5.00 * Math.Sin(fha * pi / 180), hline2, contour, 0.3);
                    }
                }
            }

            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void SteppedReamer(Dictionary<string, Object> data)  //阶梯铰刀
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc1 = Convert.ToDouble(data["dc1"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double dc3 = Convert.ToDouble(data["dc3"]) * scale;
            double dc4 = Convert.ToDouble(data["dc4"]) * scale;
            double sdl1 = Convert.ToDouble(data["sdl1"]) * scale;
            double sd4 = Convert.ToDouble(data["sd4"]) * scale;
            double sd3 = Convert.ToDouble(data["sd3"]) * scale;
            double sta2 = Convert.ToDouble(data["sta2"]) * pi / 180;
            double sta3 = Convert.ToDouble(data["sta3"]) * pi / 180;
            double sta4 = Convert.ToDouble(data["sta4"]) * pi / 180;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double plgang = Convert.ToDouble(data["plgang"]) * pi / 180;
            double df = Convert.ToDouble(data["df"]) * scale;
            double flgt = Convert.ToDouble(data["flgt"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double rcf = Convert.ToDouble(data["rcf"]) * scale;
            double nos = Convert.ToDouble(data["nos"]);
            double dcintf = Convert.ToDouble(data["dcintf"]) * scale;
            double plgl = Convert.ToDouble(data["plgl"]) * scale;
            double lpr = oal - ls;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //主视图
            if (nos == 4)
            {
                //坐标
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dconms / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(df / 2, v3.Y);
                Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
                Vector2 v6 = new Vector2(dc4 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + lcf);
                Vector2 v8 = new Vector2(v7.X - rcf, v7.Y - rcf);
                Vector2 v9 = new Vector2(v8.X, -oal);
                Vector2 v33 = new Vector2(v6.X, -oal + sd4);
                Vector2 v34 = new Vector2(dc3 / 2, v33.Y - (dc4 - dc3) / 2 / Math.Tan(sta4 / 2));
                Vector2 v35 = new Vector2(v34.X, -oal + sd3);
                Vector2 v36 = new Vector2(dc2 / 2, v35.Y - (dc3 - dc2) / 2 / Math.Tan(sta3 / 2));
                Vector2 v37 = new Vector2(v36.X, -oal + plgl + sdl1 + (dc2 - dc1) / 2 * Math.Cos(sta2 / 2) / Math.Sin(sta2 / 2));
                Vector2 v38 = new Vector2(dc1 / 2, -oal + plgl + sdl1);
                Vector2 v39 = new Vector2(v38.X, -oal + plgl);
                Vector2 v60 = new Vector2(v39.X - plgl * Math.Tan(plgang), -oal);
                Vector2 v61 = new Vector2(-v60.X, v60.Y);
                Vector2 v27 = new Vector2(-v6.X, v6.Y);
                Vector2 v28 = new Vector2(-v5.X, v5.Y);
                Vector2 v29 = new Vector2(-v4.X, v4.Y);
                Vector2 v30 = new Vector2(-v3.X, v3.Y);
                Vector2 v31 = new Vector2(-v2.X, v2.Y);
                Vector2 v32 = new Vector2(-v1.X, v1.Y);
                Vector2 v40 = new Vector2(-v39.X, v39.Y);
                Vector2 v41 = new Vector2(-v38.X, v38.Y);
                Vector2 v42 = new Vector2(-v37.X, v37.Y);
                Vector2 v43 = new Vector2(-v36.X, v36.Y);
                Vector2 v44 = new Vector2(-v35.X, v35.Y);
                Vector2 v45 = new Vector2(-v34.X, v34.Y);
                Vector2 v46 = new Vector2(-v33.X, v33.Y);
                Vector2 v47 = new Vector2(0, 2);
                Vector2 v48 = new Vector2(0, -oal - 2);
                double x51 = dc4 / 2 - rcf;
                if (v46.Y > v8.Y)
                {
                    x51 = v6.X - Math.Sqrt(rcf * rcf - (v46.Y - v8.Y) * (v46.Y - v8.Y));
                }
                double x52 = dc4 / 2 - rcf;
                if (v45.Y > v8.Y)
                {
                    x52 = v6.X - Math.Sqrt(rcf * rcf - (v45.Y - v8.Y) * (v45.Y - v8.Y));
                }
                double x53 = dc4 / 2 - rcf;
                if (v44.Y > v8.Y)
                {
                    x53 = v6.X - Math.Sqrt(rcf * rcf - (v44.Y - v8.Y) * (v44.Y - v8.Y));
                }
                double x54 = dc4 / 2 - rcf;
                if (v43.Y > v8.Y)
                {
                    x54 = v6.X - Math.Sqrt(rcf * rcf - (v43.Y - v8.Y) * (v43.Y - v8.Y));
                }
                double x55 = dc4 / 2 - rcf;
                if (v42.Y > v8.Y)
                {
                    x55 = v6.X - Math.Sqrt(rcf * rcf - (v42.Y - v8.Y) * (v42.Y - v8.Y));
                }
                double x56 = dc4 / 2 - rcf;
                if (v41.Y > v8.Y)
                {
                    x56 = v6.X - Math.Sqrt(rcf * rcf - (v41.Y - v8.Y) * (v41.Y - v8.Y));
                }
                Vector2 v51 = new Vector2(x51, v46.Y);
                Vector2 v52 = new Vector2(x52, v45.Y);
                Vector2 v53 = new Vector2(x53, v44.Y);
                Vector2 v54 = new Vector2(x54, v43.Y);
                Vector2 v55 = new Vector2(x55, v42.Y);
                Vector2 v56 = new Vector2(x56, v41.Y);
                double x62 = dc4 / 2 - rcf;
                if (v40.Y > v8.Y)
                {
                    x62 = v6.X - Math.Sqrt(rcf * rcf - (v40.Y - v8.Y) * (v40.Y - v8.Y));
                }
                Vector2 v62 = new Vector2(x62, v40.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v33 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v33, v34 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v34, v35 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v35, v36 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v36, v37 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v37, v38 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v38, v39 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line21 = { v39, v60 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line32 = { v27, v46 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v46, v45 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                Vector2[] Line34 = { v45, v44 };
                fun.drawBLine(dxf, Line34, 0.3, contour);
                Vector2[] Line35 = { v44, v43 };
                fun.drawBLine(dxf, Line35, 0.3, contour);
                Vector2[] Line36 = { v43, v42 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v42, v41 };
                fun.drawBLine(dxf, Line37, 0.3, contour);
                Vector2[] Line38 = { v41, v40 };
                fun.drawBLine(dxf, Line38, 0.3, contour);
                Vector2[] Line54 = { v61, v40 };
                fun.drawBLine(dxf, Line54, 0.3, contour);
                Vector2[] Line55 = { v61, v60 };
                fun.drawBLine(dxf, Line55, 0.3, contour);
                Vector2[] Line39 = { v27, v28 };
                fun.drawBLine(dxf, Line39, 0.3, contour);
                Vector2[] Line40 = { v28, v29 };
                fun.drawBLine(dxf, Line40, 0.3, contour);
                Vector2[] Line41 = { v29, v30 };
                fun.drawBLine(dxf, Line41, 0.3, contour);
                Vector2[] Line42 = { v30, v31 };
                fun.drawBLine(dxf, Line42, 0.3, contour);
                Vector2[] Line43 = { v31, v32 };
                fun.drawBLine(dxf, Line43, 0.3, contour);
                Vector2[] Line44 = { v32, v1 };
                fun.drawBLine(dxf, Line44, 0.3, contour);
                Vector2[] Line45 = { v31, v2 };
                fun.drawBLine(dxf, Line45, 0.3, contour);
                Vector2[] Line46 = { v30, v3 };
                fun.drawBLine(dxf, Line46, 0.3, contour);
                Vector2[] Line47 = { v27, v6 };
                fun.drawBLine(dxf, Line47, 0.3, contour);
                Vector2[] Line48 = { v46, v51 };
                fun.drawBLine(dxf, Line48, 0.3, contour);
                Vector2[] Line49 = { v45, v52 };
                fun.drawBLine(dxf, Line49, 0.3, contour);
                Vector2[] Line50 = { v44, v53 };
                fun.drawBLine(dxf, Line50, 0.3, contour);
                Vector2[] Line51 = { v43, v54 };
                fun.drawBLine(dxf, Line51, 0.3, contour);
                Vector2[] Line52 = { v42, v55 };
                fun.drawBLine(dxf, Line52, 0.3, contour);
                Vector2[] Line53 = { v47, v48 };
                fun.drawPlinetype(dxf, Line53, 0.15, center, Linetype.Center);
                Vector2[] Line56 = { v8, v9 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v41, v56 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                Vector2[] Line58 = { v40, v62 };
                fun.drawBLine(dxf, Line58, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v7));
                Arc1.Vertexes.Add(new LwPolylineVertex(v8));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                Arc Arc2 = new Arc(new Vector2(v7.X, v8.Y), rcf, 90, 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(new Vector2(0, v9.Y), new Vector2(0, v39.Y)), new Line(v60, v39), v39.X / Math.Sin(plgang) * Math.Cos(plgang), dimensionStyle);
                angdim1.UserText = "PLGANG = " + Math.Round(plgang / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v61, v40), -offset - v4.X + (v39.X + v60.X) / 2, 270, dimensionStyle);
                dim5.UserText = "PLGL = " + Math.Round(plgl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v4.X - v3.X, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v41, v40), -offset - (v4.X - v38.X), 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v35, v60), offset + v4.X - (v35.X + v60.X) / 2, 270, dimensionStyle);
                dim8.UserText = "SD_3 = " + Math.Round(sd3 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v60, v1), offset * 5 + v4.X - (v1.X + v60.X) / 2 + 0.25, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v31, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                if (sta2 != pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, v42), new Line(v38, v37), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                if (sta2 == pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, new Vector2(v42.X, v42.Y + 0.1)), new Line(v38, new Vector2(v37.X, v37.Y + 0.1)), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                //尺寸12
                /*Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, v44), new Line(v36, v35), v36.X / Math.Sin(sta3 / 2)* Math.Cos(sta3 / 2) + offset, dimensionStyle);
                angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim12);*/
                if (sta3 != pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, v44), new Line(v36, v35), v35.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                if (sta3 == pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, new Vector2(v44.X, v44.Y + 0.1)), new Line(v36, new Vector2(v35.X, v35.Y + 0.1)), v35.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                //尺寸14
                LinearDimension dim14 = new LinearDimension(new Line(v33, v60), offset * 2 + v4.X - (v33.X + v60.X) / 2, 270, dimensionStyle);
                dim14.UserText = "SD_4 = " + Math.Round(sd4 / scale, 2);
                dxf.AddEntity(dim14);
                //尺寸15
                Angular2LineDimension angdim15 = new Angular2LineDimension(new Line(v45, v46), new Line(v34, v33), v33.X / Math.Sin(sta4 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                angdim15.UserText = "STA_4 = " + Math.Round(sta4 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim15);
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v4, v5), offset, 270, dimensionStyle);
                dim16.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim16);
                //尺寸17
                LinearDimension dim17 = new LinearDimension(new Line(v7, v60), offset * 3 - (v7.X + v60.X) / 2 + v4.X, 270, dimensionStyle);
                dim17.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim17);
                //尺寸18
                LinearDimension dim18 = new LinearDimension(new Line(v4, v60), offset * 4 + (v4.X - v60.X) / 2, 270, dimensionStyle);
                dim18.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim18);
                //尺寸19
                LinearDimension dim19 = new LinearDimension(new Line(v29, v4), -flgt / 2, 0, dimensionStyle);
                dim19.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim19);
                //尺寸20
                LinearDimension dim20 = new LinearDimension(new Line(v27, v6), -(v27.Y - v46.Y) / 2, 0, dimensionStyle);
                dim20.UserText = "DC_4 = " + Math.Round(dc4 / scale, 2);
                dxf.AddEntity(dim20);
                //尺寸21
                LinearDimension dim21 = new LinearDimension(new Line(v45, v34), -(v45.Y - v44.Y), 0, dimensionStyle);
                dim21.UserText = "DC_3 = " + Math.Round(dc3 / scale, 2);
                dxf.AddEntity(dim21);
                //尺寸22
                LinearDimension dim22 = new LinearDimension(new Line(v43, v36), -(v43.Y - v42.Y), 0, dimensionStyle);
                dim22.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim22);
                //尺寸23
                LinearDimension dim23 = new LinearDimension(new Line(v41, v38), -(v41.Y - v40.Y) / 2, 0, dimensionStyle);
                dim23.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim23);
                //尺寸24
                RadialDimension dimrad24 = new RadialDimension(Arc2, 135, 0, dimensionStyle);//DimensionStyle.Default);
                dimrad24.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad24);
            }
            if (nos == 3)
            {
                //坐标
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dconms / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(df / 2, v3.Y);
                Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
                Vector2 v6 = new Vector2(dc3 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + lcf);
                Vector2 v8 = new Vector2(v7.X - rcf, v7.Y - rcf);
                Vector2 v9 = new Vector2(v8.X, -oal);
                Vector2 v35 = new Vector2(v6.X, -oal + sd3);
                Vector2 v36 = new Vector2(dc2 / 2, v35.Y - (dc3 - dc2) / 2 / Math.Tan(sta3 / 2));
                Vector2 v37 = new Vector2(v36.X, -oal + plgl + sdl1 + (dc2 - dc1) / 2 * Math.Cos(sta2 / 2) / Math.Sin(sta2 / 2));
                Vector2 v38 = new Vector2(dc1 / 2, -oal + plgl + sdl1);
                Vector2 v39 = new Vector2(v38.X, -oal + plgl);
                Vector2 v27 = new Vector2(-v6.X, v6.Y);
                Vector2 v28 = new Vector2(-v5.X, v5.Y);
                Vector2 v29 = new Vector2(-v4.X, v4.Y);
                Vector2 v30 = new Vector2(-v3.X, v3.Y);
                Vector2 v31 = new Vector2(-v2.X, v2.Y);
                Vector2 v32 = new Vector2(-v1.X, v1.Y);
                Vector2 v40 = new Vector2(-v39.X, v39.Y);
                Vector2 v41 = new Vector2(-v38.X, v38.Y);
                Vector2 v42 = new Vector2(-v37.X, v37.Y);
                Vector2 v43 = new Vector2(-v36.X, v36.Y);
                Vector2 v46 = new Vector2(-v35.X, v35.Y);
                Vector2 v47 = new Vector2(0, 2);
                Vector2 v48 = new Vector2(0, -oal - 2);
                double x51 = dc3 / 2 - rcf;
                if (v46.Y > v8.Y)
                {
                    x51 = v6.X - Math.Sqrt(rcf * rcf - (v46.Y - v8.Y) * (v46.Y - v8.Y));
                }
                double x54 = dc3 / 2 - rcf;
                if (v43.Y > v8.Y)
                {
                    x54 = v6.X - Math.Sqrt(rcf * rcf - (v43.Y - v8.Y) * (v43.Y - v8.Y));
                }
                double x55 = dc3 / 2 - rcf;
                if (v41.Y > v8.Y)
                {
                    x55 = v6.X - Math.Sqrt(rcf * rcf - (v41.Y - v8.Y) * (v41.Y - v8.Y));
                }
                double x56 = dc3 / 2 - rcf;
                if (v42.Y > v8.Y)
                {
                    x56 = v6.X - Math.Sqrt(rcf * rcf - (v42.Y - v8.Y) * (v42.Y - v8.Y));
                }
                Vector2 v51 = new Vector2(x51, v46.Y);
                Vector2 v54 = new Vector2(x54, v43.Y);
                Vector2 v55 = new Vector2(x55, v41.Y);
                Vector2 v56 = new Vector2(x56, v42.Y);
                Vector2 v60 = new Vector2(v39.X - plgl * Math.Tan(plgang), -oal);
                Vector2 v61 = new Vector2(-v60.X, v60.Y);
                double x62 = dc3 / 2 - rcf;
                if (v40.Y > v8.Y)
                {
                    x62 = v6.X - Math.Sqrt(rcf * rcf - (v40.Y - v8.Y) * (v40.Y - v8.Y));
                }
                Vector2 v62 = new Vector2(x62, v40.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v35 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line9 = { v35, v36 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v36, v37 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v37, v38 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v38, v39 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line21 = { v62, v40 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line32 = { v27, v46 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v46, v43 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                Vector2[] Line36 = { v43, v42 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v42, v41 };
                fun.drawBLine(dxf, Line37, 0.3, contour);
                Vector2[] Line38 = { v41, v40 };
                fun.drawBLine(dxf, Line38, 0.3, contour);
                Vector2[] Line39 = { v27, v28 };
                fun.drawBLine(dxf, Line39, 0.3, contour);
                Vector2[] Line40 = { v28, v29 };
                fun.drawBLine(dxf, Line40, 0.3, contour);
                Vector2[] Line41 = { v29, v30 };
                fun.drawBLine(dxf, Line41, 0.3, contour);
                Vector2[] Line42 = { v30, v31 };
                fun.drawBLine(dxf, Line42, 0.3, contour);
                Vector2[] Line43 = { v31, v32 };
                fun.drawBLine(dxf, Line43, 0.3, contour);
                Vector2[] Line44 = { v32, v1 };
                fun.drawBLine(dxf, Line44, 0.3, contour);
                Vector2[] Line45 = { v31, v2 };
                fun.drawBLine(dxf, Line45, 0.3, contour);
                Vector2[] Line46 = { v30, v3 };
                fun.drawBLine(dxf, Line46, 0.3, contour);
                Vector2[] Line47 = { v27, v6 };
                fun.drawBLine(dxf, Line47, 0.3, contour);
                Vector2[] Line48 = { v46, v51 };
                fun.drawBLine(dxf, Line48, 0.3, contour);
                Vector2[] Line51 = { v43, v54 };
                fun.drawBLine(dxf, Line51, 0.3, contour);
                Vector2[] Line52 = { v41, v55 };
                fun.drawBLine(dxf, Line52, 0.3, contour);
                Vector2[] Line53 = { v47, v48 };
                fun.drawPlinetype(dxf, Line53, 0.15, center, Linetype.Center);
                Vector2[] Line56 = { v8, v9 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v42, v56 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v7));
                Arc1.Vertexes.Add(new LwPolylineVertex(v8));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                Arc Arc2 = new Arc(new Vector2(v7.X, v8.Y), rcf, 90, 180);
                Vector2[] Line58 = { v39, v60 };
                fun.drawBLine(dxf, Line58, 0.3, contour);
                Vector2[] Line59 = { v40, v61 };
                fun.drawBLine(dxf, Line59, 0.3, contour);
                Vector2[] Line60 = { v60, v61 };
                fun.drawBLine(dxf, Line60, 0.3, contour);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(new Vector2(0, v9.Y), new Vector2(0, v39.Y)), new Line(v60, v39), v39.X / Math.Sin(plgang) * Math.Cos(plgang), dimensionStyle);
                angdim1.UserText = "PLGANG = " + Math.Round(plgang / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v61, v40), -offset - v4.X + (v39.X + v60.X) / 2, 270, dimensionStyle);
                dim5.UserText = "PLGL = " + Math.Round(plgl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v4.X - v3.X, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v41, v40), -offset - (v4.X - v38.X), 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v35, v60), offset + v4.X - (v35.X + v60.X) / 2, 270, dimensionStyle);
                dim8.UserText = "SD_3 = " + Math.Round(sd3 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v60, v1), offset * 4 + v4.X - (v1.X + v60.X) / 2 + 0.25, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v31, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                if (sta2 != pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, v42), new Line(v38, v37), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                if (sta2 == pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, new Vector2(v42.X, v42.Y + 0.1)), new Line(v38, new Vector2(v37.X, v37.Y + 0.1)), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                //尺寸12
                /*Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, v44), new Line(v36, v35), v36.X / Math.Sin(sta3 / 2)* Math.Cos(sta3 / 2) + offset, dimensionStyle);
                angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim12);*/
                if (sta3 != pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, v46), new Line(v36, v35), v35.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                if (sta3 == pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v43, new Vector2(v46.X, v46.Y + 0.1)), new Line(v36, new Vector2(v35.X, v35.Y + 0.1)), v35.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v4, v5), offset, 270, dimensionStyle);
                dim16.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim16);
                //尺寸17
                LinearDimension dim17 = new LinearDimension(new Line(v7, v60), offset * 2 - (v7.X + v60.X) / 2 + v4.X, 270, dimensionStyle);
                dim17.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim17);
                //尺寸18
                LinearDimension dim18 = new LinearDimension(new Line(v4, v60), offset * 3 + (v4.X - v60.X) / 2, 270, dimensionStyle);
                dim18.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim18);
                //尺寸19
                LinearDimension dim19 = new LinearDimension(new Line(v29, v4), -flgt / 2, 0, dimensionStyle);
                dim19.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim19);
                //尺寸20
                LinearDimension dim20 = new LinearDimension(new Line(v27, v6), -(v27.Y - v46.Y) / 2, 0, dimensionStyle);
                dim20.UserText = "DC_3 = " + Math.Round(dc3 / scale, 2);
                dxf.AddEntity(dim20);
                //尺寸22
                LinearDimension dim22 = new LinearDimension(new Line(v43, v36), -(v43.Y - v42.Y), 0, dimensionStyle);
                dim22.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim22);
                //尺寸23
                LinearDimension dim23 = new LinearDimension(new Line(v41, v38), -(v41.Y - v40.Y) / 2, 0, dimensionStyle);
                dim23.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim23);
                //尺寸24
                RadialDimension dimrad24 = new RadialDimension(Arc2, 135, 0, dimensionStyle);//DimensionStyle.Default);
                dimrad24.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad24);
            }
            if (nos == 2)
            {
                //坐标
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dconms / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(df / 2, v3.Y);
                Vector2 v5 = new Vector2(v4.X, v4.Y - flgt);
                Vector2 v6 = new Vector2(dc2 / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + lcf);
                Vector2 v8 = new Vector2(v7.X - rcf, v7.Y - rcf);
                Vector2 v9 = new Vector2(v8.X, -oal);
                Vector2 v37 = new Vector2(v6.X, -oal + plgl + sdl1 + (dc2 - dc1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v38 = new Vector2(dc1 / 2, -oal + plgl + sdl1);
                Vector2 v39 = new Vector2(v38.X, -oal + plgl);
                Vector2 v27 = new Vector2(-v6.X, v6.Y);
                Vector2 v28 = new Vector2(-v5.X, v5.Y);
                Vector2 v29 = new Vector2(-v4.X, v4.Y);
                Vector2 v30 = new Vector2(-v3.X, v3.Y);
                Vector2 v31 = new Vector2(-v2.X, v2.Y);
                Vector2 v32 = new Vector2(-v1.X, v1.Y);
                Vector2 v40 = new Vector2(-v39.X, v39.Y);
                Vector2 v41 = new Vector2(-v38.X, v38.Y);
                Vector2 v42 = new Vector2(-v37.X, v37.Y);
                Vector2 v47 = new Vector2(0, 2);
                Vector2 v48 = new Vector2(0, -oal - 2);
                double x55 = dc2 / 2 - rcf;
                if (v41.Y > v8.Y)
                {
                    x55 = v6.X - Math.Sqrt(rcf * rcf - (v41.Y - v8.Y) * (v41.Y - v8.Y));
                }
                double x56 = dc2 / 2 - rcf;
                if (v42.Y > v8.Y)
                {
                    x56 = v6.X - Math.Sqrt(rcf * rcf - (v42.Y - v8.Y) * (v42.Y - v8.Y));
                }
                Vector2 v55 = new Vector2(x55, v41.Y);
                Vector2 v56 = new Vector2(x56, v42.Y);
                Vector2 v60 = new Vector2(v39.X - plgl * Math.Tan(plgang), -oal);
                Vector2 v61 = new Vector2(-v60.X, v60.Y);
                double x62 = dc2 / 2 - rcf;
                if (v40.Y > v8.Y)
                {
                    x62 = v6.X - Math.Sqrt(rcf * rcf - (v40.Y - v8.Y) * (v40.Y - v8.Y));
                }
                Vector2 v62 = new Vector2(x62, v40.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v37 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line11 = { v37, v38 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v38, v39 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line21 = { v62, v40 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line32 = { v27, v42 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line37 = { v42, v41 };
                fun.drawBLine(dxf, Line37, 0.3, contour);
                Vector2[] Line38 = { v41, v40 };
                fun.drawBLine(dxf, Line38, 0.3, contour);
                Vector2[] Line39 = { v27, v28 };
                fun.drawBLine(dxf, Line39, 0.3, contour);
                Vector2[] Line40 = { v28, v29 };
                fun.drawBLine(dxf, Line40, 0.3, contour);
                Vector2[] Line41 = { v29, v30 };
                fun.drawBLine(dxf, Line41, 0.3, contour);
                Vector2[] Line42 = { v30, v31 };
                fun.drawBLine(dxf, Line42, 0.3, contour);
                Vector2[] Line43 = { v31, v32 };
                fun.drawBLine(dxf, Line43, 0.3, contour);
                Vector2[] Line44 = { v32, v1 };
                fun.drawBLine(dxf, Line44, 0.3, contour);
                Vector2[] Line45 = { v31, v2 };
                fun.drawBLine(dxf, Line45, 0.3, contour);
                Vector2[] Line46 = { v30, v3 };
                fun.drawBLine(dxf, Line46, 0.3, contour);
                Vector2[] Line47 = { v27, v6 };
                fun.drawBLine(dxf, Line47, 0.3, contour);
                Vector2[] Line52 = { v41, v55 };
                fun.drawBLine(dxf, Line52, 0.3, contour);
                Vector2[] Line53 = { v47, v48 };
                fun.drawPlinetype(dxf, Line53, 0.15, center, Linetype.Center);
                Vector2[] Line56 = { v8, v9 };
                fun.drawBLine(dxf, Line56, 0.3, contour);
                Vector2[] Line57 = { v42, v56 };
                fun.drawBLine(dxf, Line57, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v7));
                Arc1.Vertexes.Add(new LwPolylineVertex(v8));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                Arc Arc2 = new Arc(new Vector2(v7.X, v8.Y), rcf, 90, 180);
                Vector2[] Line58 = { v39, v60 };
                fun.drawBLine(dxf, Line58, 0.3, contour);
                Vector2[] Line59 = { v40, v61 };
                fun.drawBLine(dxf, Line59, 0.3, contour);
                Vector2[] Line60 = { v60, v61 };
                fun.drawBLine(dxf, Line60, 0.3, contour);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 3.5;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 3.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(new Vector2(0, v9.Y), new Vector2(0, v39.Y)), new Line(v60, v39), v39.X / Math.Sin(plgang) * Math.Cos(plgang), dimensionStyle);
                angdim1.UserText = "PLGANG = " + Math.Round(plgang / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v61, v40), -offset - v4.X + (v39.X + v60.X) / 2, 270, dimensionStyle);
                dim5.UserText = "PLGL = " + Math.Round(plgl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v4.X - v3.X, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v41, v40), -offset - (v4.X - v38.X), 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v60, v1), offset * 3 + v4.X - (v1.X + v60.X) / 2 + 0.25, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v31, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                if (sta2 != pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, v42), new Line(v38, v37), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                if (sta2 == pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v41, new Vector2(v42.X, v42.Y + 0.1)), new Line(v38, new Vector2(v37.X, v37.Y + 0.1)), v37.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v4, v5), offset, 270, dimensionStyle);
                dim16.UserText = "FLGT = " + Math.Round(flgt / scale, 2);
                dxf.AddEntity(dim16);
                //尺寸17
                LinearDimension dim17 = new LinearDimension(new Line(v7, v60), offset - (v7.X + v60.X) / 2 + v4.X, 270, dimensionStyle);
                dim17.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim17);
                //尺寸18
                LinearDimension dim18 = new LinearDimension(new Line(v4, v60), offset * 2 + (v4.X - v60.X) / 2, 270, dimensionStyle);
                dim18.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim18);
                //尺寸19
                LinearDimension dim19 = new LinearDimension(new Line(v29, v4), -flgt / 2, 0, dimensionStyle);
                dim19.UserText = "DF = " + Math.Round(df / scale, 2);
                dxf.AddEntity(dim19);
                //尺寸20
                LinearDimension dim20 = new LinearDimension(new Line(v27, v6), -(v27.Y - v42.Y) / 2, 0, dimensionStyle);
                dim20.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim20);
                //尺寸23
                LinearDimension dim23 = new LinearDimension(new Line(v41, v38), -(v41.Y - v40.Y) / 2, 0, dimensionStyle);
                dim23.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim23);
                //尺寸24
                RadialDimension dimrad24 = new RadialDimension(Arc2, 135, 0, dimensionStyle);//DimensionStyle.Default);
                dimrad24.UserText = "RCF = " + Math.Round(rcf / scale, 2);
                dxf.AddEntity(dimrad24);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 200 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void Bell_styleReamer(Dictionary<string, Object> data)  //钟罩式铰刀
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc1 = Convert.ToDouble(data["dc1"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double dc3 = Convert.ToDouble(data["dc3"]) * scale;//三级台阶独有
            double sdl1 = Convert.ToDouble(data["sdl1"]) * scale;
            double sdl2 = Convert.ToDouble(data["sdl2"]) * scale;//二级台阶独有
            double sdl3 = Convert.ToDouble(data["sdl3"]) * scale;//三级台阶独有
            double sd3 = Convert.ToDouble(data["sd3"]) * scale;//三级台阶独有
            double sta2 = Convert.ToDouble(data["sta2"]) * pi / 180;
            double sta3 = Convert.ToDouble(data["sta3"]) * pi / 180;//三级台阶独有
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dmm = Convert.ToDouble(data["dmm"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double plgang = Convert.ToDouble(data["plgang"]) * pi / 180;
            double nos = Convert.ToDouble(data["nos"]);
            double plgl = Convert.ToDouble(data["plgl"]) * scale;
            double bdx = Convert.ToDouble(data["bdx"]) * scale;
            double lpr = oal - ls;
            double lf = oal - plgl;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //主视图
            if (nos == 3)
            {
                //坐标
                Vector2 v1 = new Vector2(dmm / 2 - 0.5, ls);
                Vector2 v2 = new Vector2(dmm / 2, ls - 0.5);
                Vector2 v3 = new Vector2(v2.X, 0);
                Vector2 v4 = new Vector2(bdx / 2 - 0.5, v3.Y);
                Vector2 v5 = new Vector2(bdx / 2, v4.Y - 0.5);
                Vector2 v6 = new Vector2(v5.X, -lpr);
                Vector2 v7 = new Vector2(dc1 / 2 + plgl * Math.Tan(plgang), v6.Y);
                Vector2 v8 = new Vector2(dc1 / 2, v6.Y + plgl);
                Vector2 v9 = new Vector2(v8.X, v8.Y + sdl1);
                Vector2 v10 = new Vector2(dc2 / 2, v9.Y + (dc1 - dc2) / 2 / Math.Tan(sta2 / 2));
                Vector2 v11 = new Vector2(v10.X, v6.Y + sd3 - (dc2 - dc3) / 2 / Math.Tan(sta3 / 2));
                Vector2 v12 = new Vector2(dc3 / 2, v6.Y + sd3);
                Vector2 v13 = new Vector2(v12.X, v12.Y + sdl3);
                Vector2 v14 = new Vector2(v13.X - 0.5, v13.Y + 0.5);
                Vector2 v15 = new Vector2(0, v14.Y);
                Vector2 v16 = new Vector2(0, v13.Y);
                Vector2 v17 = new Vector2(0, v12.Y);
                Vector2 v18 = new Vector2(0, v11.Y);
                Vector2 v19 = new Vector2(0, v10.Y);
                Vector2 v20 = new Vector2(0, v9.Y);
                Vector2 v21 = new Vector2(0, v8.Y);
                Vector2 v22 = new Vector2(-v6.X, v6.Y);
                Vector2 v23 = new Vector2(-v5.X, v5.Y);
                Vector2 v24 = new Vector2(-v4.X, v4.Y);
                Vector2 v25 = new Vector2(-v3.X, v3.Y);
                Vector2 v26 = new Vector2(-v2.X, v2.Y);
                Vector2 v27 = new Vector2(-v1.X, v1.Y);
                Vector2 v28 = new Vector2(0, v26.Y);
                Vector2 v29 = new Vector2(0, v25.Y);
                Vector2 v30 = new Vector2(0, v23.Y);
                Vector2 v32 = new Vector2(0, v1.Y + 2);
                Vector2 v31 = new Vector2(0, v6.Y - 2);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v22 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line9 = { v7, v8 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v8, v9 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v9, v10 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v10, v11 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line21 = { v11, v12 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line32 = { v12, v13 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v13, v14 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                Vector2[] Line36 = { v14, v15 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v16, v13 };
                fun.drawBLine(dxf, Line37, 0.3, contour);
                Vector2[] Line38 = { v17, v12 };
                fun.drawBLine(dxf, Line38, 0.3, contour);
                Vector2[] Line39 = { v18, v11 };
                fun.drawBLine(dxf, Line39, 0.3, contour);
                Vector2[] Line40 = { v19, v10 };
                fun.drawBLine(dxf, Line40, 0.3, contour);
                Vector2[] Line41 = { v20, v9 };
                fun.drawBLine(dxf, Line41, 0.3, contour);
                Vector2[] Line42 = { v21, v8 };
                fun.drawBLine(dxf, Line42, 0.3, contour);
                Vector2[] Line43 = { v22, v23 };
                fun.drawBLine(dxf, Line43, 0.3, contour);
                Vector2[] Line44 = { v23, v24 };
                fun.drawBLine(dxf, Line44, 0.3, contour);
                Vector2[] Line45 = { v24, v29 };
                fun.drawBLine(dxf, Line45, 0.3, contour);
                Vector2[] Line46 = { v25, v26 };
                fun.drawBLine(dxf, Line46, 0.3, contour);
                Vector2[] Line47 = { v27, v26 };
                fun.drawBLine(dxf, Line47, 0.3, contour);
                Vector2[] Line48 = { v27, v1 };
                fun.drawBLine(dxf, Line48, 0.3, contour);
                Vector2[] Line51 = { v26, v28 };
                fun.drawBLine(dxf, Line51, 0.3, contour);
                Vector2[] Line52 = { v23, v30 };
                fun.drawBLine(dxf, Line52, 0.3, contour);
                Vector2[] Line53 = { v31, v32 };
                fun.drawPlinetype(dxf, Line53, 0.15, centre, Linetype.Center);
                //填充
                LwPolyline hatchpoly3 = new LwPolyline();
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v7));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v8));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v9));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v10));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v11));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v12));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v14));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(new Vector2(0, v1.Y)));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v1));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly3.IsClosed = true;
                String[] htype3 = new String[100];
                Line[] hline3 = new Line[100];
                int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst3; i++)
                {
                    htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype3[i] == "Line")
                    {
                        hline3[i] = (Line)hatchpoly3.Explode()[i];
                    }
                }
                fun.hatchsubofline(dxf, htype3, hnumst3, 45, 5, hline3, hatching);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 3.5;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 3.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v21, new Vector2(0, v7.Y)),new Line(v8, v7),  v7.X / Math.Sin(plgang) * Math.Cos(plgang), dimensionStyle);
                angdim1.UserText = "PLGANG = " + Math.Round(plgang / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v8, v7), offset + v6.X - (v8.X + v7.X) / 2, 270, dimensionStyle);
                dim5.UserText = "PLGL = " + Math.Round(plgl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v5.X - v3.X, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v8, v9), offset + v6.X - v8.X, 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v12, v6), offset * 2 + (v6.X - v12.X) / 2, 270, dimensionStyle);
                dim8.UserText = "SD_3 = " + Math.Round(sd3 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v6, v1), offset * 4 + (v6.X - v1.X) / 2, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v26, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                if (sta2 != pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v10, v9), new Line(new Vector2(-v10.X, v10.Y), new Vector2(-v9.X, v9.Y)), v9.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                if (sta2 == pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v10, new Vector2(v9.X, v9.Y - 0.1)), new Line(new Vector2(-v10.X, v10.Y), new Vector2(-v9.X, v9.Y - 0.1)), v9.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                //尺寸12
                if (sta3 != pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v12, v11), new Line(new Vector2(-v12.X, v12.Y), new Vector2(-v11.X, v11.Y)), v11.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                if (sta3 == pi)
                {
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v12, new Vector2(v11.X, v11.Y - 0.1)), new Line(new Vector2(-v12.X, v12.Y), new Vector2(-v11.X, v11.Y - 0.1)), v11.X / Math.Sin(sta3 / 2) * Math.Cos(sta3 / 2) + offset, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v27, v8), -offset - (v27.X + v8.X) / 2 + v22.X, 270, dimensionStyle);
                dim16.UserText = "LF = " + Math.Round(lf / scale, 2);
                dxf.AddEntity(dim16);
                //尺寸17
                LinearDimension dim17 = new LinearDimension(new Line(v12, v13), offset + v6.X - v12.X, 270, dimensionStyle);
                dim17.UserText = "SDL_3 = " + Math.Round(sdl3 / scale, 2);
                dxf.AddEntity(dim17);
                //尺寸18
                LinearDimension dim18 = new LinearDimension(new Line(v4, v6), offset * 3 + 0.25, 270, dimensionStyle);
                dim18.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim18);
                //尺寸19
                LinearDimension dim19 = new LinearDimension(new Line(v22, v6), -offset * 4, 0, dimensionStyle);
                dim19.UserText = "BDX = " + Math.Round(bdx / scale, 2);
                dxf.AddEntity(dim19);
                //尺寸20
                LinearDimension dim20 = new LinearDimension(new Line(v12, new Vector2(-v12.X, v12.Y)), -offset - (v12.Y - v6.Y), 0, dimensionStyle);
                dim20.UserText = "DC_3 = " + Math.Round(dc3 / scale, 2);
                dxf.AddEntity(dim20);
                //尺寸22
                LinearDimension dim22 = new LinearDimension(new Line(v10, new Vector2(-v10.X, v10.Y)), -offset * 2 - (v10.Y - v6.Y), 0, dimensionStyle);
                dim22.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim22);
                //尺寸23
                LinearDimension dim23 = new LinearDimension(new Line(v8, new Vector2(-v8.X, v8.Y)), -offset * 3 - (v8.Y - v6.Y), 0, dimensionStyle);
                dim23.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim23);
            }
            if (nos == 2)
            {
                //坐标
                Vector2 v1 = new Vector2(dmm / 2 - 0.5, ls);
                Vector2 v2 = new Vector2(dmm / 2, ls - 0.5);
                Vector2 v3 = new Vector2(v2.X, 0);
                Vector2 v4 = new Vector2(bdx / 2 - 0.5, v3.Y);
                Vector2 v5 = new Vector2(bdx / 2, v4.Y - 0.5);
                Vector2 v6 = new Vector2(v5.X, -lpr);
                Vector2 v7 = new Vector2(dc1 / 2 + plgl * Math.Tan(plgang), v6.Y);
                Vector2 v8 = new Vector2(dc1 / 2, v6.Y + plgl);
                Vector2 v9 = new Vector2(v8.X, v8.Y + sdl1);
                Vector2 v10 = new Vector2(dc2 / 2, v9.Y + (dc1 - dc2) / 2 / Math.Tan(sta2 / 2));
                Vector2 v13 = new Vector2(v10.X, v10.Y + sdl2);
                Vector2 v14 = new Vector2(v13.X - 0.5, v13.Y + 0.5);
                Vector2 v15 = new Vector2(0, v14.Y);
                Vector2 v16 = new Vector2(0, v13.Y);
                Vector2 v19 = new Vector2(0, v10.Y);
                Vector2 v20 = new Vector2(0, v9.Y);
                Vector2 v21 = new Vector2(0, v8.Y);
                Vector2 v22 = new Vector2(-v6.X, v6.Y);
                Vector2 v23 = new Vector2(-v5.X, v5.Y);
                Vector2 v24 = new Vector2(-v4.X, v4.Y);
                Vector2 v25 = new Vector2(-v3.X, v3.Y);
                Vector2 v26 = new Vector2(-v2.X, v2.Y);
                Vector2 v27 = new Vector2(-v1.X, v1.Y);
                Vector2 v28 = new Vector2(0, v26.Y);
                Vector2 v29 = new Vector2(0, v25.Y);
                Vector2 v30 = new Vector2(0, v23.Y);
                Vector2 v32 = new Vector2(0, v1.Y + 2);
                Vector2 v31 = new Vector2(0, v6.Y - 2);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v22 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line9 = { v7, v8 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v8, v9 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v9, v10 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v10, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line33 = { v13, v14 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                Vector2[] Line36 = { v14, v15 };
                fun.drawBLine(dxf, Line36, 0.3, contour);
                Vector2[] Line37 = { v16, v13 };
                fun.drawBLine(dxf, Line37, 0.3, contour);
                Vector2[] Line40 = { v19, v10 };
                fun.drawBLine(dxf, Line40, 0.3, contour);
                Vector2[] Line41 = { v20, v9 };
                fun.drawBLine(dxf, Line41, 0.3, contour);
                Vector2[] Line42 = { v21, v8 };
                fun.drawBLine(dxf, Line42, 0.3, contour);
                Vector2[] Line43 = { v22, v23 };
                fun.drawBLine(dxf, Line43, 0.3, contour);
                Vector2[] Line44 = { v23, v24 };
                fun.drawBLine(dxf, Line44, 0.3, contour);
                Vector2[] Line45 = { v24, v29 };
                fun.drawBLine(dxf, Line45, 0.3, contour);
                Vector2[] Line46 = { v25, v26 };
                fun.drawBLine(dxf, Line46, 0.3, contour);
                Vector2[] Line47 = { v27, v26 };
                fun.drawBLine(dxf, Line47, 0.3, contour);
                Vector2[] Line48 = { v27, v1 };
                fun.drawBLine(dxf, Line48, 0.3, contour);
                Vector2[] Line51 = { v26, v28 };
                fun.drawBLine(dxf, Line51, 0.3, contour);
                Vector2[] Line52 = { v23, v30 };
                fun.drawBLine(dxf, Line52, 0.3, contour);
                Vector2[] Line53 = { v31, v32 };
                fun.drawPlinetype(dxf, Line53, 0.15, centre, Linetype.Center);
                //填充
                LwPolyline hatchpoly3 = new LwPolyline();
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v4));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v5));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v6));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v7));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v8));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v9));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v10));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v13));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v14));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v15));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(new Vector2(0, v1.Y)));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v1));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v2));
                hatchpoly3.Vertexes.Add(new LwPolylineVertex(v3));
                hatchpoly3.IsClosed = true;
                String[] htype3 = new String[100];
                Line[] hline3 = new Line[100];
                int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst3; i++)
                {
                    htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype3[i] == "Line")
                    {
                        hline3[i] = (Line)hatchpoly3.Explode()[i];
                    }
                }
                fun.hatchsubofline(dxf, htype3, hnumst3, 45, 5, hline3, hatching);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 3.5;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 3.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v8, v7), new Line(v21, new Vector2(0, v7.Y)), v7.X / Math.Sin(plgang) * Math.Cos(plgang), dimensionStyle);
                angdim1.UserText = "PLGANG = " + Math.Round(plgang / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v8, v7), offset + v6.X - (v8.X + v7.X) / 2, 270, dimensionStyle);
                dim5.UserText = "PLGL = " + Math.Round(plgl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v5.X - v3.X, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v8, v9), offset + v6.X - v8.X, 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v6, v1), offset * 3 + (v6.X - v1.X) / 2, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v26, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                if (sta2 != pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v10, v9), new Line(new Vector2(-v10.X, v10.Y), new Vector2(-v9.X, v9.Y)), v9.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                if (sta2 == pi)
                {
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v10, new Vector2(v9.X, v9.Y - 0.1)), new Line(new Vector2(-v10.X, v10.Y), new Vector2(-v9.X, v9.Y - 0.1)), v9.X / Math.Sin(sta2 / 2) * Math.Cos(sta2 / 2) + offset, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                }
                //尺寸16
                LinearDimension dim16 = new LinearDimension(new Line(v27, v8), -offset - (v27.X + v8.X) / 2 + v22.X, 270, dimensionStyle);
                dim16.UserText = "LF = " + Math.Round(lf / scale, 2);
                dxf.AddEntity(dim16);
                //尺寸17
                LinearDimension dim17 = new LinearDimension(new Line(v10, v13), offset + v6.X - v10.X, 270, dimensionStyle);
                dim17.UserText = "SDL_3 = " + Math.Round(sdl3 / scale, 2);
                dxf.AddEntity(dim17);
                //尺寸18
                LinearDimension dim18 = new LinearDimension(new Line(v4, v6), offset * 2 + 0.25, 270, dimensionStyle);
                dim18.UserText = "LPR = " + Math.Round(lpr / scale, 2);
                dxf.AddEntity(dim18);
                //尺寸19
                LinearDimension dim19 = new LinearDimension(new Line(v22, v6), -offset * 3, 0, dimensionStyle);
                dim19.UserText = "BDX = " + Math.Round(bdx / scale, 2);
                dxf.AddEntity(dim19);
                //尺寸22
                LinearDimension dim22 = new LinearDimension(new Line(v10, new Vector2(-v10.X, v10.Y)), -offset - (v10.Y - v6.Y), 0, dimensionStyle);
                dim22.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim22);
                //尺寸23
                LinearDimension dim23 = new LinearDimension(new Line(v8, new Vector2(-v8.X, v8.Y)), -offset * 2 - (v8.Y - v6.Y), 0, dimensionStyle);
                dim23.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim23);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 200 - oal / 2 + ls));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ShellReamer(Dictionary<string, Object> data)  //套式铰刀
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dcon = Convert.ToDouble(data["dcon"]) * scale;
            double ds = dcon - oal / 30;
            double l = Convert.ToDouble(data["l"]) * scale;
            double plgang = Convert.ToDouble(data["plgang"]) * pi / 180;
            double plgl = Convert.ToDouble(data["plgl"]) * scale;
            double df = Convert.ToDouble(data["df"]) * scale;
            double bcdp = Convert.ToDouble(data["bcdp"]) * scale;
            double lf = oal - plgl;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //主视图
            //坐标
            Vector2 v1 = new Vector2(dcon / 2, 0);
            Vector2 v2 = new Vector2(df / 2, 0);
            Vector2 v3 = new Vector2(v2.X, -oal + l + (dc - df) / 2);
            Vector2 v4 = new Vector2(dc / 2, -oal + l);
            Vector2 v5 = new Vector2(v4.X, -oal + plgl);
            Vector2 v6 = new Vector2(v5.X - plgl * Math.Tan(plgang), -oal);
            Vector2 v7 = new Vector2(v5.X - bcdp, v6.Y);
            Vector2 v8 = new Vector2(v7.X, v3.Y);
            Vector2 v9 = new Vector2(ds / 2, v7.Y);
            Vector2 v10 = new Vector2(-v9.X, v9.Y);
            Vector2 v11 = new Vector2(-v7.X, v7.Y);
            Vector2 v12 = new Vector2(-v8.X, v8.Y);
            Vector2 v13 = new Vector2(-v6.X, v6.Y);
            Vector2 v14 = new Vector2(-v5.X, v5.Y);
            Vector2 v15 = new Vector2(-v4.X, v4.Y);
            Vector2 v16 = new Vector2(-v3.X, v3.Y);
            Vector2 v17 = new Vector2(-v2.X, v2.Y);
            Vector2 v18 = new Vector2(-v1.X, v1.Y);
            Vector2 v19 = new Vector2(0, 2);
            Vector2 v20 = new Vector2(0, -oal - 2);
            //线段
            Vector2[] Line1 = { v17, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v13 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line9 = { v7, v8 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v8, v3 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v9, v1 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v10, v18 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line21 = { v11, v12 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line32 = { v12, v16 };
            fun.drawBLine(dxf, Line32, 0.3, contour);
            Vector2[] Line33 = { v13, v14 };
            fun.drawBLine(dxf, Line33, 0.3, contour);
            Vector2[] Line36 = { v14, v15 };
            fun.drawBLine(dxf, Line36, 0.3, contour);
            Vector2[] Line37 = { v16, v15 };
            fun.drawBLine(dxf, Line37, 0.3, contour);
            Vector2[] Line38 = { v17, v16 };
            fun.drawBLine(dxf, Line38, 0.3, contour);
            Vector2[] Line53 = { v19, v20 };
            fun.drawPlinetype(dxf, Line53,0.15, centre, Linetype.Center);
            //填充
            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v7));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsubofline(dxf, htype2, hnumst2, 45, 5, hline2, hatching);
            LwPolyline hatchpoly3 = new LwPolyline();
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v18));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly3.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly3.IsClosed = true;
            String[] htype3 = new String[100];
            Line[] hline3 = new Line[100];
            int hnumst3 = hatchpoly3.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst3; i++)
            {
                htype3[i] = hatchpoly3.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype3[i] == "Line")
                {
                    hline3[i] = (Line)hatchpoly3.Explode()[i];
                }
            }
            fun.hatchsubofline(dxf, htype3, hnumst3, 45, 5, hline3, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v6, v5), new Line(v6, new Vector2(v6.X, v5.Y)), offset, dimensionStyle);
            angdim1.UserText = "PLGANG = " + Math.Round(plgang / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v5, v6), offset * 2 + (v5.X - v6.X) / 2, 270, dimensionStyle);
            dim5.UserText = "PLGL = " + Math.Round(plgl / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v4, v6), offset * 3 + (v4.X - v6.X) / 2, 270, dimensionStyle);
            dim6.UserText = "L = " + Math.Round(l / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v6, v2), offset * 4 + v4.X - (v6.X + v2.X) / 2, 270, dimensionStyle);
            dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v1, v18), offset, 0, dimensionStyle);
            dim10.UserText = "DCON = " + Math.Round(dcon / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸16
            LinearDimension dim16 = new LinearDimension(new Line(v17, v14), -offset - (v17.X - v14.X) / 2, 270, dimensionStyle);
            dim16.UserText = "LF = " + Math.Round(lf / scale, 2);
            dxf.AddEntity(dim16);
            //尺寸22
            LinearDimension dim22 = new LinearDimension(new Line(v14, v5), -offset - (v5.Y - v6.Y), 0, dimensionStyle);
            dim22.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim22);
            //尺寸23
            LinearDimension dim23 = new LinearDimension(new Line(v17, v2), offset * 2, 0, dimensionStyle);
            dim23.UserText = "DF = " + Math.Round(df / scale, 2);
            dxf.AddEntity(dim23);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 200 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}

